<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>实验室设备管理系统</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="../../static/layui/css/layui.css"  media="all">
  <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body style="height: 600px">

<table class="layui-table" id="test" >
<!-- lay-data="{width: 892, height:332, url:'/demo/table/user/', page:true, id:'idTest'}" lay-filter="demo" -->
  <thead>
    <tr>
      <th lay-data="{field:'sort', width:80, sort: true, fixed: left}">序号</th>
      <th lay-data="{field:'kind', width:80}">设备类型</th>
      <th lay-data="{field:'name', width:80, sort: true}">设备名称</th>
      <th lay-data="{field:'id', width:80}">设备编号</th>
      <th lay-data="{field:'room', width:140}">设备所在实验室</th>
      <th lay-data="{field:'teacher', width:80, sort: true}">负责教师</th>
      <th lay-data="{field:'tphone', width:80}">教师电话</th>
      <th lay-data="{field:'state', width:40, sort: true}">状态</th>
      <th lay-data="{field:'student', width:80, sort: true, fixed: 'right'}">借用学生</th>
      <th lay-data="{field:'snum', width:80, sort: true}">学生学号</th>
      <th lay-data="{field:'sphone', width:80, sort: true, fixed: 'right'}">学生电话</th>
      <th lay-data="{fixed: 'right', width:178, toolbar: '#barDemo'}">操作</th>
    </tr>
  </thead>
  <tbody>
    {% block table %}
    {% for equipment in equipments %}
    <tr data-index="0" class="">
    <td data-field="sort">
      <div class="layui-table-cell">{{ forloop.counter }}</div>
    </td>
    <td data-field="sort">
      <div class="layui-table-cell">{{ equipment.eKind }}</div>
    </td>
    <td data-field="sort">
      <div class="layui-table-cell">{{ equipment.eName }}</div>
    </td>
    <td data-field="sort">
      <div class="layui-table-cell">{{ equipment.id }}</div>
    </td>
    <td data-field="sort">
      <div class="layui-table-cell">{{ equipment.eRoom }}</div>
    </td>
    <td data-field="sort">
      <div class="layui-table-cell">{{ equipment.eTeacher.tName }}</div>
    </td>
    <td data-field="sort">
      <div class="layui-table-cell">{{ equipment.eTeacher.tPhone }}</div>
    </td>
    <td data-field="sort">
      <div class="layui-table-cell">{{ equipment.eState }}</div>
    </td>
    <td data-field="sort">
      <div class="layui-table-cell">{{ equipment.eStudent.userName }}</div>
    </td>
    <td data-field="sort">
      <div class="layui-table-cell">{{ equipment.eStudent.userNum }}</div>
    </td>
    <td data-field="sort">
      <div class="layui-table-cell">{{ equipment.eStudent.userPhone }}</div>
    </td>
    <td data-field="10" align="center" data-off="true">
      <div class="layui-table-cell laytable-cell-1-10">
        <a class="edit layui-btn layui-btn-xs" lay-event="edit" data-url=edit?eid={{equipment.id}}><i class="layui-icon"></i></a>
        <a class="del layui-btn layui-btn-danger layui-btn-xs" lay-event="del"  data-url=delete?eid={{equipment.id}}><i class="layui-icon"></i></a>
      </div>
    </td>
    </tr>
    {% endfor %}
    {% endblock %}
  </tbody>

</table>

<script src="../../static/layui/layui.js" type="text/javascript"></script>
<script src="../../static/layui/lay/modules/jquery.js" type="text/javascript"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script type="text/javascript">

  layui.use('layer', function(){
    var layer = layui.layer;
    var $ = layui.jquery;
    $(".del").click(function() {
      var url = $(this).attr("data-url");
      $.get(url,function(data,status){
        console.log(layer);
        layer.msg(data, {time: 1000}, function() {
          location.href = location.href;
        });
        // console.log(location.href);
        // alert(data);
      });
    });

  });

</script>

<script type="text/javascript">
layui.use('layer', function(){
    var layer = layui.layer;
    var $ = layui.jquery;
    $(".edit").click(function() {
      var url = $(this).attr("data-url");
     layer.open({
                type: 2 //此处以iframe举例
                , title: '更新设备信息'
                , area: ['700px', '400px']
                , shade: 0
                , maxmin: true
                , offset: '10px'
                , content: url
                , btn: ['关闭'] //只是为了演示
                , end: function () {
                location.reload();}
            });
    });

  });
layui.use('laypage', function(){
  var laypage = layui.laypage;

  //执行一个laypage实例
  laypage.render({
    elem: 'test1' //注意，这里的 test1 是 ID，不用加 # 号
    ,count: 50 //数据总数，从服务端得到
  });
});
</script>
</body>
</html>